package com.lvmama.rhino.entrance

import com.lvmama.rhino.analyze.client._
import com.lvmama.rhino.analyze.external.{DataProvider, VIPCustomerService}
import com.lvmama.rhino.analyze.nginx.{ManGodPageFlow, MsyPageStat}
import com.lvmama.rhino.analyze.push._
import com.lvmama.rhino.common.utils.Utils
import com.lvmama.rhino.streaming.SearchSuggest
import com.lvmama.rhino.streaming.nginx.ManGodStatStreaming

/**
  * ━━━━━━神兽出没━━━━━━
  * 　　　┏┓　　　┏┓
  * 　　┏┛┻━━━┛┻┓
  * 　　┃　　　　　　　┃
  * 　　┃　　　━　　　┃
  * 　　┃　┳┛　┗┳　┃
  * 　　┃　　　　　　　┃
  * 　　┃　　　┻　　　┃
  * 　　┃　　　　　　　┃
  * 　　┗━┓　　　┏━┛
  * 　　　　┃　　　┃神兽保佑, 永无BUG!
  * 　　　　 ┃　　　┃Code is far away from bug with the animal protecting
  * 　　　　┃　　　┗━━━┓
  * 　　　　┃　　　　　　　┣┓
  * 　　　　┃　　　　　　　┏┛
  * 　　　　┗┓┓┏━┳┓┏┛
  * 　　　　　┃┫┫　┃┫┫
  * 　　　　　┗┻┛　┗┻┛
  * ━━━━━━━━━━━━━━━━
  * Created by yuanxiaofeng on 2016\\5\\4.
  */
object JobExecute {
  def main(args: Array[String]) {
    val hdfsPath = "hdfs://hadoop/source_data/"
    val jobs: Option[String] => Unit = {
      //batch
      case Some("ManGodPageFlowJob") => ManGodPageFlow.execute(args(1), Nil)
      case Some("DetailLogTopKJob") => DetailLogTopK(args(1), args(2).toInt)
      case Some("MsyPageStatJob") => MsyPageStat(args(1))
      case Some("AIMachineStatJob") => AIMachineStat(args(1), args(2).toInt)
      case Some("WirelessStatJob") => WirelessStat(if (args.length >= 2) args(1) else Utils.getYesterday("yyyy/MM/dd"))
      case Some("WirelessStatPitJob") => WirelessStatPit(if (args.length >= 2) args(1) else Utils.getYesterday("yyyy/MM/dd"))

      //超级自由行
      case Some("SuperFreeTravel") => SuperFreeTravel(if (args.length >= 2) args(1) else Utils.getYesterday("yyyy/MM/dd"))

      //用户操作路径清洗job
      case Some("WirelessOperPathStatJob") => WirelessOperPathStat(if (args.length >= 2) args(1) else Utils.getYesterday("yyyy/MM/dd"))

      //推荐推送转化统计job
      case Some("RecPushCovStatJob") => RecPushCovStat(if (args.length >= 2) args(1) else Utils.getYesterday("yyyy/MM/dd"))

      case Some("PreProcessWirelessStatJob") => PreProcessWireless(if (args.length >= 2) args(1) else Utils.getYesterday("yyyy/MM/dd"),
        if (args.length >= 3) args(2) else Utils.getYesterday("yyyy/MM/dd"))
      //streaming job
      case Some("SearchSuggestStreaming") => SearchSuggest.execute(Option("local[2]"), args.tail.toList, Nil)
      case Some("ManGodStatStreaming") => ManGodStatStreaming()

      case Some("Wireless_ver2Streaming") => WirelessStatVer2(args(1).toLong)
      case Some("PreStatStreaming") => PreProcessWirelessStreaming(args(1).toLong)

      //推送相关统计
      case Some("PushCallbackJob") => PushCallbackJob(args(1))
      case Some("InvalidDeviceInit") => InvalidDeviceInit()
      case Some("CustomInvalidDeviceCollect") => CustomInvalidDeviceCollect(args(1).toInt)
      case Some("UserClickAnalysis") => UserClickAnalysis()
      //structured streaming
      case Some("WirelessStatVer2Batch") => WirelessStatVer2Batch(if (args.length >= 2) args(1) else Utils.getYesterday("yyyy/MM/dd"))
      //h5页面访问时长监控
      case Some("H5PageMonitorJob") => H5PageMonitor(hdfsPath + "nginx/h5page/" + Utils.getYesterday("yyyy/MM/dd"))

      //性能统计
      case Some("PerformanceMonitorJob") => PerformanceMonitor(hdfsPath + "nginx/monitor_kafka/" + Utils.getYesterday("yyyy/MM/dd") + "/*")

     //NPS统计
//      case Some("WirelessNpsJob") => WirelessNps(args(1).toLong)

      //数据提供
      case Some("DataProvider") => DataProvider(args(1).toLong)
      case Some("VIPCustomerService") => VIPCustomerService(if (args.length >= 2) args(1) else Utils.getToday("yyyy/MM/dd/"))
      //会员精准营销
      case Some("VIPMarketing") =>VIPMarketing(args(1).toLong)
      case Some("VIPMarketingStreaming") => VIPMarketingStreaming(args(1).toLong)

      //性能统计二期--页面监控
      case Some("MonitorPageJob") => MonitorPage(hdfsPath + "nginx/monitorPage_kafka/" + Utils.getYesterday("yyyy/MM/dd"))
      //性能统计二期--接口详细信息
      case Some("MonitorApiJob") => MonitorApi(hdfsPath + "nginx/monitor_kafka/" + Utils.getLastHourDate())
      case Some("MonitorApiStreaming") => MonitorApiStreaming(args(1).toLong)

      //鹰眼系统二期--页面详细信息
      case Some("MonitorPageStreaming") => MonitorPageStreaming(args(1).toLong)
      //鹰眼系统二期--页面Js错误信息
      case Some("MonitorPageJsStreaming") => MonitorPageJsStreaming(args(1).toLong)
      //临时job 修复数据
      case Some("VIPTempJob") => VIPTemp(if (args.length >= 2) args(1) else Utils.getYesterday("yyyy/MM/dd")+"-"+Utils.getYesterday("yyyy/MM/dd"))

      case _ => println("rhino pipeline no job to execute !!!!!!!")
    }
    jobs(Option[String](args.head))
    //    System.exit(0)
  }
}
